<div class="easyui-layout" data-options="fit:true">
    <!-- Begin of toolbar -->
    <div id="wu-toolbar-la">
        <div class="wu-toolbar-button">
            <a href="#" class="easyui-linkbutton" iconCls="icon-add" onclick="openAddLa()" plain="true">添加</a>
            <a href="#" class="easyui-linkbutton" iconCls="icon-edit" onclick="openEditLa()" plain="true">修改</a>
            <a href="#" class="easyui-linkbutton" iconCls="icon-remove" onclick="removeLa()" plain="true">删除</a>
            <a href="#" class="easyui-linkbutton" iconCls="icon-remove" onclick="reloadLa()" plain="true">刷新</a>
        </div>
        <div class="wu-toolbar-search">

            <!-- <label>栏目：</label>
            <input id="lm-select" class="easyui-combobox" style="width:200px"> -->


            <label>标题：</label>
            <input class="wu-text" id="title-input" style="width:100px">
            <a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="selectByTitle()">开始检索</a>

        </div>
    </div>
    <!-- End of toolbar -->
    <table id="wu-datagrid-la" class="easyui-datagrid" toolbar="#wu-toolbar-la"></table>

</div>

<!-- Begin of easyui-dialog -->
<div id="wu-dialog-la" class="easyui-dialog" data-options="closed:true,maximizable:true,maximized:true,iconCls:'icon-save'"
    style="width:1200px; padding:10px;top:10px;">
    <form id="wu-form-la" method="post" class="easyui-form">
        <table cellpadding="5">
            <tr>
                <td>文章标题:</td>
                <td>
                    <input class="easyui-validatebox" required="true" type="text" name="title">
                </td>
                <td>
                    <span class="news-pic-title" style="display: none">请上传首页展示图：</span>
                </td>
                <td rowspan="7" style="">
                    <div class="news-pic-box" style="position:relative; display: none">
                        <div class="pic-box" style="width:504px;height:280px; ">
                            <img class="upimg-btn" src="/admin/images/phone.png" style="width: 100%;height:100%" alt="">
                            <input class="easyui-filebox" type="file" required="required" onchange="change_photo()" id="file_upload" name="file_upload2"
                                title="点我上传图片" onchange="change_photo()" style="width:100%;height:100%;display:block;position:absolute;top:0px;left:0px;opacity:0;">
                        </div>

                    </div>
                </td>
            </tr>
            <tr>
                <td>子标题:</td>
                <td>
                    <input class="easyui-textbox" name="htitle" data-options="required:true">
                </td>
            </tr>

            <tr>
                <td>发布单位/部门:</td>
                <td>
                    <input class="easyui-validatebox" required="true" type="text" name="zz">
                </td>
            </tr>

            <tr>
                <td>是否通过审核:</td>
                <td>
                    <select class="easyui-combobox" id="sh" name="sh" data-options="required:true,fit:true,editable:false">
                        <option value="1">通过</option>
                        <option value="0">不通过</option>
                    </select>
                </td>
            </tr>

            <tr>
                <td>是否推荐:</td>
                <td>
                    <select class="easyui-combobox" id="tj" name="tj" data-options="fit:true,editable:false" required="true" onChange="change()">
                        <option value="推荐">推荐</option>
                        <option value="不推荐">不推荐</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>是否签收:</td>
                <td>
                    <select class="easyui-combobox" id="qs" name="QianShou" style="width:135px;" required="required"></select>
                </td>
            </tr>

            <tr id="qianshou-box" style="display:none;">
                <td>签收人:</td>
                <td>
                    <select class="easyui-combobox" id="qs-users" name="needQIanShouUsers" style="width:135px;"></select>
                    <input type="checkbox" id="user-checked-box">全选
                </td>
            </tr>

            <tr>
                <td>选择栏目:</td>
                <td>
                    <select id="lm-select1" class="easyui-combobox" style="width:135px;" name="lm" required="required"></select>
                </td>
            </tr>

            <tr>
                <td>新闻内容:</td>
                <td colspan="3">
                    <!-- <textarea rows="3" id="content" name="content" required="required"></textarea> -->
                    <!--KindEditor编辑器-->
                    <textarea rows="3" id="content" name="content" required="required"></textarea>

                </td>
            </tr>
            <input type="text" style="display:none" name="id">
            <input type="text" style="display:none" name="preview_id" id="preview_id">
            <input type="text" style="display:none" name="username">
            <input type="text" style="display:none" name="pic" id="pic-path">
        </table>
    </form>
</div>

<!-- End of easyui-dialog -->
<script type="text/javascript">
    // 控制显示和隐藏
    $("#qs").combobox({
        onChange: function (n, o) {
            if (n == 1) {
                $('#qianshou-box').show();
            } else {
                $('#qianshou-box').hide();
            }
        }
    });
    $("#lm-select1").combobox({

        onSelect: function (row) {
            // console.log(row.lm)
            if (row.lm == "图片新闻") {

                $(".news-pic-title").show();
                $(".news-pic-box").show();

            } else {
                $(".news-pic-title").hide();
                $(".news-pic-box").hide();
            }
        },


    });

    $.ajax({
        type: 'post',
        url: $.webConfig.apiUrl + 'xsuser/getxs',
        data: {
            page: 1,
            rows: 9000
        },
        dataType: 'json',
        success: function (data) {
            if (data['return_code'] == 1) {
                $.xsUser = data['return_body'];
                var xsObj = {};
                var xsIdArr = [];
                $.each(data['return_body'], function (key, val) {
                    xsObj[val['id']] = val;
                    xsIdArr.push(val['id']);
                });
                $.xsObj = xsObj;
                $.xsIdArr = xsIdArr;
                $('#qs-users').combobox({
                    valueField: 'id',
                    textField: 'username',
                    data: $.xsUser,
                    editable: false,
                    multiple: true
                });
            }
        },
        error: function (err) {
            console.log(err)
        }
    });

    // 全选反选
    $('#user-checked-box').on('change', function () {
        if ($('#user-checked-box').get(0).checked) {
            $('#qs-users').combobox('setValues', $.xsIdArr);
        } else {
            $('#qs-users').combobox('setValue', null);
        }
    });

    $.qianshou = [{
            "id": 0,
            "QianShou": "不需要签收"
        },
        {
            "id": 1,
            "QianShou": "需要签收"
        }
    ]
    // 栏目下拉

    var userObj = JSON.parse($.cookie('gn_userObj'))

    $('#isSuperAdministrator').val(userObj['isSuperAdministrator']);

    $.ajax({
        type: 'post',
        url: $.webConfig.apiUrl + 'lm/getlmById',
        data: {
            id: userObj['id'],
            type: userObj['isSuperAdministrator']

        },
        dataType: 'json',
        success: function (data) {
            if (data['return_code'] == 1) {
                // $('#lm-select').combobox({
                //     valueField: 'id',
                //     textField: 'lm',
                //     data: data['return_body']
                // });
                // $('#lm-select').combobox('setValue', data['return_body'][0]['id']);
                $.lmData = data['return_body'];

                var lmObj = {};
                $.each(data['return_body'], function (key, val) {
                    lmObj[val['id']] = val;
                })
                $.lmObj = lmObj;
            }
        },
        error: function (err) {
            console.log(err)
        }
    })



    // 模糊查询
    function selectByTitle() {
        var title = $('#title-input').val();
        $('#wu-datagrid-la').datagrid('load', {
            id: JSON.parse($.cookie('gn_userObj'))['id'],
            type: JSON.parse($.cookie('gn_userObj'))['isSuperAdministrator'],
            addname: JSON.parse($.cookie('gn_userObj'))['username'] ? JSON.parse($.cookie('gn_userObj'))[
                'username'] : JSON.parse($.cookie('gn_userObj'))['user'],
            title: title
        });
    }


    /**
     * Name 添加记录
     */
    function add() {
        var str = $('#qs-users').combobox('getValues').join(",");
        $('#qs-users').combobox('setValue', str);
        if (str == '' && str.length == 0) {
            $('#wu-form-la').form('load', {
                'QianShou': 0
            });
        }
        // 检查是否已上传图片
        console.log($("#pic-path").val());
        if ($('#lm-select1').combobox("getText") == "图片新闻") {
            if (!$("#pic-path").val()) {

                $.messager.alert('信息提示', '请选择图片', 'info');
                return;
            }
        }


        // 检查是否登陆超时
        var user_str = $.cookie('gn_userObj');
        if (!user_str) {
            alert('登陆超时');
            window.location.href = "/app/login.html";
        }
        var user_obj = JSON.parse(user_str);

        console.log(user_obj);
        var username;
        // 判断是否是管理员，因为cookie里面存的字段不一样
        if (user_obj.user) {
            username = user_obj.user;
        } else {
            username = user_obj.username;
        }
        console.log(username)
        $('#wu-form-la').form('load', {
            'username': username
        });

        $('#wu-form-la').form('submit', {
            url: $.webConfig.apiUrl + 'news/addnews',
            success: function (data) {
                var data = JSON.parse(data);
                if (data['return_code'] == 1) {
                    $.messager.alert('信息提示', '提交成功！', 'info');
                    $('#wu-dialog-la').dialog('close');
                    $('#wu-datagrid-la').datagrid('reload');
                    $('#wu-form-la').form('clear');
                } else {
                    $.messager.alert('信息提示', '提交失败！', 'info');
                }
            }
        });
    }

    /**
     * Name 修改记录
     */
    function edit() {
        var str = $('#qs-users').combobox('getValues').join(",");
        $('#qs-users').combobox('setValue', str);

        if (str == '' && str.length == 0) {
            $('#wu-form-la').form('load', {
                'QianShou': 0
            });
        }

        $('#wu-form-la').form('submit', {
            url: $.webConfig.apiUrl + 'news/upnews',
            success: function (data) {
                var data = JSON.parse(data);
                if (data['return_code'] == 1) {
                    $.messager.alert('信息提示', '提交成功！', 'info');
                    $('#wu-dialog-la').dialog('close');
                    $('#wu-datagrid-la').datagrid('reload');
                    $('#wu-form-la').form('clear');
                } else {
                    $.messager.alert('信息提示', '提交失败！', 'info');
                }
            }
        });
    }

    /**
     * Name 删除记录
     */
    function removeLa() {
        var items = $('#wu-datagrid-la').datagrid('getSelections');
        if (items.length == 0) {
            $.messager.alert('信息提示', '你没选中哦...', 'info');
            return;
        }
        $.messager.confirm('信息提示', '确定要删除该记录？', function (result) {
            if (result) {
                var items = $('#wu-datagrid-la').datagrid('getSelections');
                var ids = [];
                $(items).each(function () {
                    ids.push(this.id);
                });

                console.log(ids)

                if (!items) {
                    $.messager.alert('信息提示', '你没选中哦...', 'info');
                    return;
                }

                //alert(ids);return;
                $.ajax({
                    type: 'post',
                    url: $.webConfig.apiUrl + 'news/delnews',
                    data: {
                        id: ids[0]
                    },
                    success: function (data) {
                        if (data) {
                            $.messager.alert('信息提示', '删除成功！', 'info');
                            $('#wu-datagrid-la').datagrid('reload');
                        } else {
                            $.messager.alert('信息提示', '删除失败！', 'info');
                        }
                    }
                });
            }
        });
    }

    var editor;
    // var pasterMgr = new WordPasterManager();ss
    // pasterMgr.Config["PostUrl"] = "http://localhost:80/gongan/admin/libs/WordPasterKindEditor4x/php/upload.php";
    // pasterMgr.Config["Cookie"] = 'PHPSESSID=<?php echo session_id() ?>';
    // pasterMgr.Load();

    function initEditor(content) {
        setTimeout(function () {

            // var editor;
            // KindEditor.ready(function (K) {
            //     editor = K.create('#content', {
            //         items: [
            //             'source', '|', 'undo', 'redo', '|', 'preview', 'print',
            //             'template', 'cut', 'copy', 'paste',
            //             'plainpaste', 'wordpaste', 'wordpaster', '|', 'justifyleft',
            //             'justifycenter', 'justifyright',
            //             'justifyfull', 'insertorderedlist', 'insertunorderedlist',
            //             'indent', 'outdent', 'subscript',
            //             'superscript', 'clearhtml', 'quickformat', 'selectall', '|',
            //             'fullscreen', '/',
            //             'formatblock', 'fontname', 'fontsize', '|', 'forecolor',
            //             'hilitecolor', 'bold',
            //             'italic', 'underline', 'strikethrough', 'lineheight',
            //             'removeformat', '|', 'image',
            //             'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons',
            //             'pagebreak',
            //             'link', 'unlink', '|', 'about'
            //         ],
            //         afterCreate: function () {
            //             pasterMgr.SetEditor(this);
            //             var self = this;
            //             KindEditor.ctrl(self.edit.doc, 'V', function () {
            //                 pasterMgr.Paste();
            //             });
            //         }
            //     });
            // });
            if (!editor) {

                editor = KindEditor.create('textarea[name="content"]', {
                    resizeType: 1,
                    width: "996px",
                    height: "900px",
                    autoHeightMode: true,
                    cssPath: '/admin/libs/WordPasterKindEditor4x/plugins/code/prettify.css',
                    uploadJson: '/admin/libs/WordPasterKindEditor4x/php/upload_json.php',
                    fileManagerJson: '/admin/libs/WordPasterKindEditor4x/php/file_manager_json.php',
                    allowFileManager: true,

                    // items: [
                    //     'source', '|', 'undo', 'redo', '|', 'preview', 'print',
                    //     'template', 'cut', 'copy', 'paste',
                    //     'plainpaste', 'wordpaste', 'wordpaster', '|', 'justifyleft',
                    //     'justifycenter', 'justifyright',
                    //     'justifyfull', 'insertorderedlist', 'insertunorderedlist',
                    //     'indent', 'outdent', 'subscript',
                    //     'superscript', 'clearhtml', 'quickformat', 'selectall', '/',
                    //     'formatblock', 'fontname', 'fontsize', '|', 'forecolor',
                    //     'hilitecolor', 'bold',
                    //     'italic', 'underline', 'strikethrough', 'lineheight',
                    //     'removeformat', '|', 'image',
                    //     'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons',
                    //     'pagebreak',
                    //     'link', 'unlink', '|', 'about'
                    // ],
                    // afterCreate: function () {
                    //     pasterMgr.SetEditor(this);
                    //     var self = this;
                    //     KindEditor.ctrl(self.edit.doc, 'V', function () {
                    //         pasterMgr.Paste();
                    //     });
                    //     // this.loadPlugin('autoheight'); //加载时同步编辑区自动高度

                    // },

                    // afterChange: function () {

                    // },
                    afterBlur: function () {
                        this.sync();
                    }
                });
            }

            if (content) {
                editor.html(content);
            }
        }, 0);

        // 设置默认值
        var shdata = $('#sh').combobox('getData');
        $('#sh').combobox('select', shdata[0].value);
        var tjdata = $('#tj').combobox('getData');
        $('#tj').combobox('select', tjdata[0].value);
        // var qsdata = $('#qs').combobox('getData');
        // $('#qs').combobox('select', qsdata[0].value);
    }

    // 预览功能
    function preview() {

        // console.log($('#wu-form-la').form);
        // console.log($('#content').val());
        // window.location.href = '/app/detail_preview.html';

        var str = $('#qs-users').combobox('getValues').join(",");
        $('#qs-users').combobox('setValue', str);
        if (str == '' && str.length == 0) {
            $('#wu-form-la').form('load', {
                'QianShou': 0
            });
        }
        // 检查是否已上传图片
        // console.log($("#pic-path").val());
        // if ($('#lm-select1').combobox("getText") == "图片新闻") {
        //     if (!$("#pic-path").val()) {

        //         $.messager.alert('信息提示', '请选择图片', 'info');
        //         return;
        //     }
        // }


        // 检查是否登陆超时
        var user_str = $.cookie('gn_userObj');
        if (!user_str) {
            alert('登陆超时');
            window.location.href = "/app/login.html";
        }
        var user_obj = JSON.parse(user_str);

        console.log(user_obj);
        var username;
        // 判断是否是管理员，因为cookie里面存的字段不一样
        if (user_obj.user) {
            username = user_obj.user;
        } else {
            username = user_obj.username;
        }
        console.log(username)
        $('#wu-form-la').form('load', {
            'username': username
        });

        $('#wu-form-la').form('submit', {
            url: $.webConfig.apiUrl + 'newspreview/addnewspreview',
            success: function (data) {
                var data = JSON.parse(data);
                if (data['return_code'] == 1) {
                    // $.messager.alert('信息提示', '提交成功！', 'info');
                    // $('#wu-dialog-la').dialog('close');
                    // $('#wu-datagrid-la').datagrid('reload');
                    // $('#wu-form-la').form('clear');
                    $("#preview_id").val(data['id']);
                    window.open("/app/detail_preview.html?articleid=" + data['id']);
                    console.log("/app/detail_preview.html?articleid=" + data['id'])
                } else {
                    $.messager.alert('信息提示', '提交失败！', 'info');
                }
            }
        });
    }



    /**
     * Name 打开添加窗口
     */
    function openAddLa() {

        setTimeout(function () {
            console.log($('#lm-select1').combobox("getText"))
            if ($('#lm-select1').combobox("getText") == "图片新闻") {
                $('.upimg-btn').attr('src', '/admin/images/phone.png');
                $("#pic-path").val('');
                $(".news-pic-title").show();
                $(".news-pic-box").show();

            } else {
                $(".news-pic-title").hide();
                $(".news-pic-box").hide();
            }
        }, 0);


        $('#wu-form-la').form('clear');
        $('#wu-dialog-la').dialog({
            closed: false,
            modal: true,
            cache: false,

            title: "添加信息",
            buttons: [{
                    text: '预览',
                    iconCls: 'icon-search',
                    handler: preview
                },
                {
                    text: '确定',
                    iconCls: 'icon-ok',
                    handler: add
                }, {
                    text: '取消',
                    iconCls: 'icon-cancel',
                    handler: function () {
                        $('#wu-dialog-la').dialog('close');
                    }
                }
            ]
        });

        // 选择是否签收
        $('#qs').combobox({
            valueField: 'id',
            textField: 'QianShou',
            data: $.qianshou,
            editable: false,
            onLoadSuccess: function () { //加载完成后,val[0]写死设置选中第一项
                var val = $(this).combobox("getData");
                for (var item in val[0]) {
                    if (item == "id") {
                        $(this).combobox("setValue", val[0][item]);
                    }
                }
            }
        });
        $('#qianshou-box').hide();

        // 选择栏目
        $('#lm-select1').combobox({
            valueField: 'id',
            textField: 'lm',
            data: $.lmData,
            editable: false,
            onLoadSuccess: function () { //加载完成后,val[0]写死设置选中第一项
                var val = $(this).combobox("getData");
                for (var item in val[0]) {
                    if (item == "id") {
                        // $(this).combobox("setValue", val[0][item]);
                    }
                }
            }
        });
        initEditor();
    }


    /**
     * Name 打开修改窗口
     */
    function openEditLa() {

        var item = $('#wu-datagrid-la').datagrid('getSelected');

        if (!item) {
            $.messager.alert('信息提示', '你没选中哦...', 'info');
            return;
        }

        setTimeout(function () {
            console.log(item)
            if ($('#lm-select1').combobox("getText") == "图片新闻") {
                $('.upimg-btn').attr('src', item.pic);
                $("#pic-path").val(item.pic);
                $(".news-pic-title").show();
                $(".news-pic-box").show();

            } else {
                $(".news-pic-title").hide();
                $(".news-pic-box").hide();
            }
        }, 0);

        console.log(item.needQIanShouUsers)
        if (item.needQIanShouUsers && item.needQIanShouUsers.split) {
            item.needQIanShouUsers = item.needQIanShouUsers.split(',');
        } else {
            item.needQIanShouUsers = '';
        }

        if (item.QianShou == 1) {
            $('#qianshou-box').show();
        } else {
            $('#qianshou-box').hide();
        }


        $('#wu-form-la').form('load', item);
        // console.log(item); //  0 是为  不用签收    1 是需要签收


        $('#qs').combobox({
            valueField: 'id',
            textField: 'QianShou',
            data: $.qianshou,
            editable: false,
            onLoadSuccess: function () { //加载完成后,val[0]写死设置选中第一项
                console.log($.qianshou)
                console.log(item["qianShou"])
                $(this).combobox("setValue", item['qianShou']);
            }
        });

        // 栏目选择
        $('#lm-select1').combobox({
            valueField: 'id',
            textField: 'lm',
            data: $.lmData,
            editable: false,
            onLoadSuccess: function () { //加载完成后,val[0]写死设置选中第一项
                console.log($.lmData)
                $(this).combobox("setValue", item['lm']);
            }
        });

        $('#wu-dialog-la').dialog({
            closed: false,
            modal: true,
            title: "修改信息",
            cache: false,
            buttons: [{
                text: '预览',
                iconCls: 'icon-search',
                handler: preview
            }, {
                text: '确定',
                iconCls: 'icon-ok',
                handler: edit
            }, {
                text: '取消',
                iconCls: 'icon-cancel',
                handler: function () {
                    $('#wu-dialog-la').dialog('close');
                }
            }]
        });

        initEditor(item.content);
    }

    /**
     * Name 分页过滤器
     */
    function pagerFilter(data) {

        var pageData = {
            total: 18,
            rows: []
        };

        if (data['return_code'] == 1) {
            pageData['total'] = data['return_count'];
            pageData['rows'] = data['return_body'];
        }

        return pageData;
    }


    var shObj = {
        1: {
            id: 1,
            title: '通过'
        },
        0: {
            id: 0,
            title: '未通过'
        }
    }

    /**
     * Name 载入数据
     */
    $('#wu-datagrid-la').datagrid({
        queryParams: {
            id: JSON.parse($.cookie('gn_userObj'))['id'],
            type: JSON.parse($.cookie('gn_userObj'))['isSuperAdministrator'],
            addname: JSON.parse($.cookie('gn_userObj'))['username'] ? JSON.parse($.cookie('gn_userObj'))[
                'username'] : JSON.parse($.cookie('gn_userObj'))['user'],
            title: ''
        },
        url: $.webConfig.apiUrl + 'news/getnews',
        loadFilter: pagerFilter,
        rownumbers: true,
        singleSelect: true,
        pageSize: 20,
        pagination: true,
        multiSort: false,
        fitColumns: true,
        fit: true,
        columns: [
            [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'id',
                    width: 100,
                    sortable: true
                },
                {
                    field: 'title',
                    title: '标题',
                    width: 180,
                    sortable: true
                },
                // {
                //     field: 'content',
                //     title: '内容',
                //     hidden: true,
                //     width: 100
                // },
                {
                    field: 'htitle',
                    title: '副标题',
                    width: 100
                },
                {

                    field: 'qianShou',
                    title: '是否签收',
                    width: 100,
                    formatter: function (value, row, index) {
                        if (row.qianShou == 1) {

                            return "需要签收"

                        } else {

                            return "不需要签收"
                        }

                    }
                },
                {
                    field: 'zz',
                    title: '发布单位/部门',
                    width: 120
                },
                {
                    field: 'time',
                    title: '发布时间',
                    width: 165,
                    formatter: function (value) {
                        var fmt = "yyyy-MM-dd hh:mm:ss";
                        var data = new Date(value);
                        var o = {
                            "M+": data.getMonth() + 1, //月份 
                            "d+": data.getDate(), //日 
                            "h+": data.getHours(), //小时 
                            "m+": data.getMinutes(), //分 
                            "s+": data.getSeconds(), //秒 
                            "q+": Math.floor((data.getMonth() + 3) / 3), //季度 
                            "S": data.getMilliseconds() //毫秒 
                        };

                        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (data.getFullYear() + "").substr(
                            4 -
                            RegExp.$1.length));
                        for (var k in o)
                            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (
                                RegExp.$1.length ==
                                1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                        return fmt;
                    }
                },
                {
                    field: 'adduser',
                    title: '用户名',
                    width: 100
                },
                {
                    field: 'lm',
                    title: '栏目',
                    width: 100,
                    formatter: function (value, row, index) {
                        if ($.lmObj && $.lmObj[value]) {
                            return $.lmObj[value]['lm'];
                        } else {
                            return value;
                        }

                    }
                },
                {
                    field: 'sh',
                    title: '是否通过审核',
                    width: 100,
                    formatter: function (value, row, index) {
                        if (shObj && shObj[value]) {
                            return shObj[value]['title'];
                        } else {
                            return value;
                        }

                    }
                },
                {
                    field: 'tj',
                    title: '是否推荐',
                    width: 100
                }, {
                    field: 'hit',
                    title: '浏览量',
                    width: 100
                }
            ]
        ]
    });
    // 刷新页面
    function reloadLa() {
        $('#wu-datagrid-la').datagrid('reload', {
            id: JSON.parse($.cookie('gn_userObj'))['id'],
            type: JSON.parse($.cookie('gn_userObj'))['isSuperAdministrator'],
            addname: JSON.parse($.cookie('gn_userObj'))['username'] ? JSON.parse($.cookie('gn_userObj'))[
                'username'] : JSON.parse($.cookie('gn_userObj'))['user'],
            title: ''

        });
    }



    // ajax 异步上传
    function ajaxFileUpload() {
        $.ajaxFileUpload({
            url: '/upload.php', //用于文件上传的服务器端请求地址
            secureuri: false, //是否需要安全协议，一般设置为false
            fileElementId: 'file_upload', //文件上传域的ID
            dataType: 'json', //返回值类型 一般设置为json
            success: function (data, status) //服务器成功响应处理函数
            {
                if (data['status'] == true) {
                    $('.upimg-btn').attr('src', data['path'][0]);
                    $("#pic-path").val(data['path'][0]);
                    // 清空
                    var file = $('#file_upload');
                    file.after(file.clone().val(""));
                    file.remove();
                } else {
                    $.messager.alert('信息提示', data['error'][0], 'info');
                }
            },
            error: function (data, status, e) //服务器响应失败处理函数
            {
                console.log(data)
            }
        })
        return false;
    }




    // 图片上传
    function change_photo() {
        ajaxFileUpload();
        // PreviewImage($("input[name='file_upload2']")[0], 'Img', 'Imgdiv');
    }
</script>